from collections import defaultdict


class Solution:
    def canConstruct(self, ransomNote: str, magazine: str) -> bool:
        mid_dic = defaultdict(int)
        for alpha in magazine:
            mid_dic[alpha] += 1
        for alpha in ransomNote:
            mid_dic[alpha] -= 1
            if mid_dic[alpha] < 0:
                return False
        return True
